/*
 * comlan
 */

package com.promfy.userinterface.bindservice.basicbindservice;


import android.app.Activity;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.promfy.R;

public class BasicBindServiceActivity extends Activity implements OnClickListener {
	
	private Button start;
	private Button destroy;
	private Button rebind;
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.basic_bind_service);
		// Bind to the service
		Intent bindIntent = new Intent(BasicBindServiceActivity.this, BasicBindServiceService.class);
		bindService(bindIntent, mConnection, Context.BIND_AUTO_CREATE);
		
		start = (Button) findViewById(R.id.start);
		destroy = (Button) findViewById(R.id.destroy);
		rebind = (Button) findViewById(R.id.rebind);
		
		start.setOnClickListener(this);
		destroy.setOnClickListener(this);
		rebind.setOnClickListener(this);
		
		}

	// Reference to the service
	private BasicBindServiceService serviceBinder;

	// Handles the connection between the service and activity
	private ServiceConnection mConnection = new ServiceConnection() {
		public void onServiceConnected(ComponentName className, IBinder service) {
			// Called when the connection is made.
			
			serviceBinder = ((BasicBindServiceService.MyBinder) service).getService();
		}

		
		
		public void onServiceDisconnected(ComponentName className) {
			// Received when the service unexpectedly disconnects.
			serviceBinder = null;
		}
	};

	@Override
	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.start:

			break;
		case R.id.destroy:
			
			break;
		case R.id.rebind:
			
			break;

		default:
			break;
		}
		
	}
}
